//  this library.
import 'package:hktk_app/ienum/my/asset_status_enum.dart';
import 'package:hktk_app/model/home/column_model.dart';

/// 我购买的资源类型
class AssetVoModel {
  // 科目id
  int? categoryId;

  // 科目名
  String? categoryName;

  // 有效期
  String? efficientTime;

  // 有效期状态,effective(有效, 1), invalid(无效, 2),  overdue(过期, 3),
  AssetStatusEnum? efficientStatus;

  // 栏目集合
  List<ColumnModel>? columnModels;

  AssetVoModel({
    this.categoryId,
    this.categoryName,
    this.efficientTime,
    this.efficientStatus,
    this.columnModels,
  });

  AssetVoModel.fromJson(Map<String, dynamic> json) {
    categoryId = json["categoryId"];
    categoryName = json["categoryName"];
    efficientTime = json["efficientTime"];
    efficientStatus = json["efficientStatus"] != null
        ? AssetStatusEnum.getTypeEnum(json["efficientStatus"])
        : null;
    if (json["columnModels"] != null) {
      columnModels = <ColumnModel>[];
      json["columnModels"].forEach((v) {
        columnModels!.add(ColumnModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data["categoryId"] = categoryId;
    data["categoryName"] = categoryName;
    data["efficientTime"] = efficientTime;
    if (efficientStatus != null) {
      data["efficientStatus"] = efficientStatus!.name;
    }
    if (columnModels != null) {
      data["columnModels"] = columnModels!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}
